import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;

import twitter4j.*;

public class TwitterClient {

    public static void main(String[] args) {
	// display current Teets in my stream of messages
		tweetList();
	}
	
	//public static void tweetList(){
		try {

			// gets Twitter instance with default credentials
			Twitter twitter = new TwitterFactory().getInstance();
			User user = twitter.verifyCredentials();
			List<Status> statuses = twitter.getHomeTimeline();
			List<String> tweets = new ArrayList<String>();
			System.out.println("Showing @" + user.getScreenName() + "'s home timeline.");
			for (Status status : statuses) 
			{
			
			if(status.getUser().getScreenName().equals("FP_Team4")){
				System.out.println("@" + status.getUser().getScreenName() + " - " +
				status.getText() + " - " + status.getCreatedAt());
				//take our tweets with timestamps and put them into an arraylist of strings
				tweets.add(status.getId() + "," + status.getInReplyToStatusId() + "," + status.getInReplyToUserId() + "," + status.getCreatedAt() + "," + status.getSource() + "," + status.getText() + "," + status.getRetweetedStatus() + "," + status.getCurrentUserRetweetId());
			}
			}
			for(int i=0;i<tweets.size();i++){
				System.out.println(tweets.get(i));
			}

		}

		catch (TwitterException te) {
		        
			te.printStackTrace();
		        System.out.println("Failed to get timeline: " + te.getMessage());
		                
		}
	}
	
	//public ArrayList tweetList(){
		try {

				// gets Twitter instance with default credentials
				Twitter twitter = new TwitterFactory().getInstance();
				User user = twitter.verifyCredentials();
				List<Status> statuses = twitter.getHomeTimeline();
				List<String> tweets = new ArrayList<String>();
				System.out.println("Showing @" + user.getScreenName() + "'s home timeline.");
				for (Status status : statuses) 
				{
			
				if(status.getUser().getScreenName().equals("FP_Team4")){
					System.out.println("@" + status.getUser().getScreenName() + " - " +
					status.getText() + " - " + status.getCreatedAt());
					//take our tweets with timestamps and put them into an arraylist of strings
					tweets.add(status.getId() + "," + status.getInReplyToStatusId() + "," + status.getInReplyToUserId() + "," + status.getCreatedAt() + "," + status.getSource() + "," + status.getText() + "," + status.getRetweetedStatus() + "," + status.getCurrentUserRetweetId());
				}
				}
				for(int i=0;i<tweets.size();i++){
					System.out.println(tweets.get(i));
				}
				return tweets();
			}

			catch (TwitterException te) {
				    
				te.printStackTrace();
				    System.out.println("Failed: " + te.getMessage());	
				return null;            
			}
	}

}
